use "C:\Users\ibo6\OneDrive - The Pennsylvania State University\Working Papers\Target Hardening\v10 Terrorism and Political Violence\R & R\Analysis\rdyads2.dta", replace

generate s = total > 0 

* TABLE 7a
** Model 29: Soft Targets (simple)
heckman softtot str_intel_log_l a_l suictot_l i.year, select(s = str_intel_log_l a_l pop_log i.year) vce(cluster dyadid)
estimates store t1_soft_simpleYEAR

** Model 30: Soft Targets (extended)
heckman softtot str_intel_log_l a_l suictot_l coin_deaths_log_l inten epr ib2.ideology i.year, select(s = str_intel_log_l a_l coin_deaths_log_l pop_log i.year) vce(cluster dyadid)

estimates store t1_soft_extendedYEAR

** Model 31: Civilian Targets Only (extended)
heckman civitot str_intel_log_l a_l suictot_l coin_deaths_log_l inten epr ib2.ideology i.year, select(s = str_intel_log_l a_l coin_deaths_log_l pop_log i.year) vce(cluster dyadid)

estimates store t1_civi_extendedYEAR

** Model 32: Hard Targets (extended)
heckman hardtot str_intel_log_l a_l suictot_l coin_deaths_log_l inten epr ib2.ideology i.year, select(s = str_intel_log_l a_l coin_deaths_log_l pop_log i.year) vce(cluster dyadid)

estimates store t1_hard_extendedYEAR

** Model 33: Mlitary Targets Only (extended)
heckman militot str_intel_log_l a_l suictot_l coin_deaths_log_l inten epr ib2.ideology i.year, select(s = str_intel_log_l a_l coin_deaths_log_l pop_log i.year) vce(cluster dyadid)
estimates store t1_mili_extendedYEAR

ssc install estout
label variable str_intel_log_l "Hardening (lagged)"
label variable a_l "Success rate against hard targets (lagged)"
label variable suictot_l "Ratio of suicide attacks (lagged)"
label variable coin_deaths_log_l "COIN casualties (lagged)"
label variable inten "Conflict intensity"
label variable epr "Ethnic fractionalization"
label variable ideology "Group ideology"
label variable mao "Maoist insurgency"
label variable kashmir "Kashmir insurgency"
label variable north "Northeast insurgency"
label variable gdp_per_log "Logged GDP per capita"


label define ideology 1 "Ethnonationalist" 2 "Religious" 3 "Leftist" 4 "Other"
label values ideology ideology


esttab t1_soft_simpleYEAR t1_soft_extendedYEAR t1_civi_extendedYEAR t1_hard_extendedYEAR t1_mili_extendedYEAR using apptable7A.csv, b(%5.3f) mlabel("Soft" "Soft" "Civilian" "Hard" "Military") se starlevels(* 0.1 ** 0.05 *** 0.01) label noconstant nobaselevels title("Heckman Selection Models of Target Selection in Relevant State-Group Dyads in India, 2004-2016: Year Dummies") addnotes("Heckman Selection Models are estimated using full maximum likelihood with Stata's heckman command. The bottom half of the table presents estimations of the selection equation. The selection criteria is whether or not a given relevant state-group dyad experienced at least 1 insurgent attack in a given year. The upper half of the table presents estimations of prevalence of attacks against respective target types. The dependent variables are the ratio of number of attacks against respective target types to total number of attacks committed in a given relevant state-group dyad in a given year. State population is logged. Robust standard errors clustered on relevant state-group dyads are presented in parantheses.")
